$(function() {

	//1、全局token开始
	var url =  window.parent.parent.location.href;
	var token = url.split("token")[1];
	token=token.slice(1);
	//var token = window.localStorage.getItem("token");
	//1、全局token结束

	//2、解析出上下文逻辑开始
	var context = getRootPath();
	//2、解析出上下文逻辑结束


	//全局变量
	var pageNumber = 1;
	var pageSize = 5;

	function getUrl() {

		var url = context + 'delay/list';
		return url;
	}


	//3、角色分页列表页面开始
	var vue = new Vue({
		el: '#delayListTable',
		data: {
			delays: [],
			// pageNumber 第几页
			pageNumber: pageNumber,

			// pageSize   1页多少条
			pageSize: pageSize,

			// totalPage 共多少页
			totalPage: 0,

			// totalCounter 一共多少条记录
			totalCounter: 0
		},
		methods: {
			//拿到角色分页列表的数据
			getDelayListPage: function(pageNumber, pageSize) {
				var sendData = {
					token: token,
					pageNumber: pageNumber,
					pageSize: pageSize
				}
				axios.post(getUrl(), sendData).then(function(dataR) {
					console.log(dataR);
					var code = dataR.data.code;

					var data = dataR.data.data;
					var delayList = data.delayList;

					var pageNumber = data.pageNumber;
					var totalCounter = data.totalCounter;
					var totalPage = data.totalPage;

					vue.delays = delayList;
					vue.pageNumber = pageNumber;
					vue.totalCounter = totalCounter;
					vue.totalPage = totalPage;

				});

			},

		}
	});
	vue.getDelayListPage(pageNumber, pageSize);
	//3、角色分页列表页面结束


	//3、下1页
	$('#nextPage').click(function() {
		if (vue.pageNumber < vue.totalPage) {
			vue.pageNumber = vue.pageNumber + 1;
			vue.getDelayListPage(vue.pageNumber, vue.pageSize);
		}
	});
	//3、下1页

	//3、最后1页
	$('#lastPage').click(function() {
		if (vue.pageNumber < vue.totalPage) {
			vue.getDelayListPage(vue.totalPage, vue.pageSize);
		}
	});
	//3、最后

	//4、上1页
	$('#prePage').click(function() {
		if (vue.pageNumber >= 2) {
			vue.pageNumber = vue.pageNumber - 1;
			vue.getDelayListPage(vue.pageNumber, vue.pageSize);
		}
	});

	//5、第1页
	$('#firstPage').click(function() {
		vue.getDelayListPage(1, vue.pageSize);
	});

});
